var e = require("../../@babel/runtime/helpers/toConsumableArray"),
  t = require("../../@babel/runtime/helpers/slicedToArray"),
  r = require("../../@babel/runtime/helpers/regeneratorRuntime"),
  n = require("../../@babel/runtime/helpers/asyncToGenerator"),
  i = require("../../store/index"),
  o = require("../../core/mini-redux/index"),
  u = require("./data"),
  a = require("./utils"),
  s = $.getMenuButtonBoundingClientRect(),
  c = s.top,
  l = s.height;
Page((0, o.connectPage)((function (e) {
  var t;
  return {
    userInfo: e.user.userInfo,
    isLogin: !(null === (t = e.storage.userInfo) || void 0 === t || !t.token)
  }
}))({
  data: {
    headerStyle: {
      paddingTop: c,
      height: l
    },
    record: u.RECORD,
    banner: [],
    modules: [{
      item: [{
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/78mTu01682048980.png",
          jump_type: "uri",
          jump_url: "/machine/myRelease",
          module_site: "2",
          title: "我的发布"
        },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/u2687t1688720211.png",
          jump_type: "uri",
          jump_url: "/machine/equipment/list",
          module_site: "2",
          title: "我的设备"
        },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/%E5%8F%91%E7%A5%A8.png",
          jump_type: "uri",
          jump_url: "/invoice/manage/index",
          module_site: "2",
          title: "发票管理"
        },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/%E7%90%86%E8%B4%A2.png",
          jump_type: "uri",
          jump_url: "/machine/coin/get",
          module_site: "2",
          title: "钱包管理"
        }
      ],
      module_site: 2,
      title: '我的服务'
    }, {
      item: [
        // {
        //   icon: "http://statics.zhaogongdi.com/images/icon/20230421/0xx0M01682048758.png",
        //   jump_type: "uri",
        //   jump_url: "/machine/report",
        //   module_site: "3",
        //   title: "意见反馈"
        // },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/user-privacy.png",
          jump_type: "uri",
          jump_url: "user-privacy",
          module_site: "3",
          title: "用户协议"
        },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/private-privacy.png",
          jump_type: "uri",
          jump_url: "private-privacy",
          module_site: "3",
          title: "隐私协议"
        },
        {
          icon: "https://excavator-container.oss-cn-hangzhou.aliyuncs.com/file/26um6m1682048771.png",
          jump_type: "uri",
          jump_url: "/machine/setting",
          module_site: "3",
          title: "设置"
        }
      ],
      module_site: 3,
      title: '设置与帮助'
    }],
    menuConfig: [{
      icon: "https://statics.zhaogongdi.com/images/web/user-privacy.png",
      jump_type: "uri",
      jump_url: "user-privacy",
      module_site: "3",
      title: "用户协议"
    }, {
      icon: "https://statics.zhaogongdi.com/images/web/private-privacy.png",
      jump_type: "uri",
      jump_url: "private-privacy",
      module_site: "3",
      title: "隐私协议"
    }]
  },
  onShow: function () {
    this.getUserInfo()
  },
  getUserInfo() {
    var that = this;
    $.request["GET/auth/info"]().then(res => {
      var code = res[0].code
      var data = res[0].data
      if (code === 20002) {
        that.setData({
          userInfo: data
        })
      }

    })
  },
  requestMemberData: function () {
    var e = this;
    return n(r().mark((function t() {
      var n, o, u, s, c, l;
      return r().wrap((function (t) {
        for (;;) switch (t.prev = t.next) {
          case 0:
            return t.prev = 0, t.next = 3, (0, i.dispatch)(i.actions.userActions.fetchUserInfo({}));
          case 3:
            c = t.sent, l = (0, a.getRecord)([null !== (n = c.coin_balance) && void 0 !== n ? n : 0, null !== (o = c.collect_number) && void 0 !== o ? o : 0, null !== (u = c.view_number) && void 0 !== u ? u : 0, null !== (s = c.contact_number) && void 0 !== s ? s : 0]), e.setData({
              record: l
            }), t.next = 11;
            break;
          case 8:
            t.prev = 8, t.t0 = t.catch(0), console.error(t.t0);
          case 11:
          case "end":
            return t.stop()
        }
      }), t, null, [
        [0, 8]
      ])
    })))()
  },
  goMemberPage: function () {
    $.router.push("/subpackage/personal/member/index")
  },
  goMyRecordPage: function (e) {
    $.router.push(e.detail)
  },
  onPullDownRefresh: function () {
    this.requestMemberData().finally((function () {
      wx.stopPullDownRefresh()
    }))
  },
  getModuleConfig: function () {
    var i = this;
    return n(r().mark((function n() {
      var o, u, a, s, c, l, d;
      return r().wrap((function (r) {
        for (;;) switch (r.prev = r.next) {
          case 0:
            return r.next = 2, $.request["GET/v2/setting/module-config"]({
              source: "XCX"
            });
          case 2:
            o = r.sent, u = t(o, 1), 200 === (a = u[0]).code && (c = a.content, console.log(c), l = (null === (s = c.find((function (e) {
              return 1 == e.module_site
            }))) || void 0 === s ? void 0 : s.item) || [], (d = c.filter((function (e) {
              return 1 != e.module_site
            }))).forEach((function (t) {
              3 === t.module_site && (t.item = [].concat(e(t.item), e(i.data.menuConfig)))
            })), console.log(l), console.log(d), i.setData({
              banner: l,
              modules: d
            }));
          case 6:
          case "end":
            return r.stop()
        }
      }), n)
    })))()
  }
}));